home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / turbcpat / patch.doc < prev    next >
Text File  |  1987-05-29  |  3KB  |  68 lines

  1. PATCH.COM
  2.  
  3. Syntax: patch [-u] dif_file prog_file [out_file]
  4.  
  5. PATCH.COM reads the text from dif_file and applies the patch to prog_file.
  6. The diff file is relatively free format. Any number of spaces or tabs can
  7. appear between two values, and any number of spaces, tabs, and blank lines
  8. can appear between lines.  The file consists of zero or more pairs of lines
  9. in the following format:
  10.  
  11.    offset: newbyte [newbyte ...]
  12.            oldbyte [oldbyte ...]
  13.  
  14. All values are represented in the file using hexidecimal digits.  The value
  15. of offset can range from 0 to 7FFFFFFF hex.  The values of new and old bytes
  16. can range from 0 to FF hex.
  17.  
  18. ----------------------------------- Example --------------------------------
  19.     6:  88
  20.         85
  21.  1DEE:  74 1A 52 7F FF 77 00
  22.         73 00 1A 52 7F ff 77
  23.  
  24. 03636: 053 08  5B     19 71 8  5B    19
  25.  
  26. 00 00   00 00 00 00  00 0
  27. ----------------------------------------------------------------------------
  28.  
  29. As you can see from the first two pairs, the diff file is more readable when
  30. formatted nicely.  But, you can be pretty flexible as shown in the third
  31. pair of lines.  Note: The first line of each pair contains the new byte values
  32. while the second line contains the old byte values.
  33.  
  34. When applying a patch, PATCH.COM makes a first pass to check that all bytes
  35. in the file which will be changed, currently match the old values which are
  36. defined in dif_file.  If they don't, an error message is printed and the
  37. patch is not applied.  If they do match, all the corresponding bytes are
  38. changed to their new values.  If any error occurs during this second step,
  39. it is most likely an out of disk space error.  During the update, a backup
  40. copy of your original file (.BAK) is kept.  This means you need twice as
  41. much disk space if your input and output files are on the same disk drive.
  42. In case of an error, the temporary file is usually deleted and the .BAK file
  43. is renamed back to the original name.  If something else goes wrong, like a
  44. power outage, you should still have your original file on the disk with a
  45. .BAK extension.
  46.  
  47. After the patch is completed:
  48.   If the output file is the same as the input file, the .BAK file is deleted.
  49.   If the output file is different than the input file, the .BAK file is
  50.   renamed back to its original name.
  51.  
  52. The -u option cause PATCH.COM to undo the patch defined in dif_file.  In this
  53. case, it checks that all the bytes to be modified match the new byte values
  54. on the first line of each pair.  It then changes the corresponding bytes to
  55. the old byte values defined on the second line of each pair.
  56.  
  57. The last parameter (out_file) is optional.  If defined, the patched version
  58. of the original file will be saved under the name specified by out_file, and
  59. the original file will be left intact.  If it is not specified, the patched
  60. version of the file will have the same name as the original version of the
  61. file, and the original version of the file will be lost.
  62.  
  63. Note:  Because PATCH.COM checks the old values of each byte to be patched,
  64. two or more patches which affect the same byte must be applied in order.
  65. Also, because of the fixed offsets defined in dif_file, the same dif_file will
  66. probably not be usable with multiple versions of the program file being
  67. patched.
  68.